const { DataTypes } = require('sequelize');
const sequelize = require('../config/database');

const Task = sequelize.define('Task', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  fileId: {
    type: DataTypes.INTEGER,
    allowNull: false
  },
  printerId: {
    type: DataTypes.INTEGER,
    allowNull: false
  },
  status: {
    type: DataTypes.ENUM('pending', 'printing', 'completed', 'failed'),
    allowNull: false,
    defaultValue: 'pending'
  },
  copies: {
    type: DataTypes.INTEGER,
    allowNull: false,
    defaultValue: 1
  },
  color: {
    type: DataTypes.BOOLEAN,
    allowNull: false,
    defaultValue: false
  },
  colorMode: {
    type: DataTypes.ENUM('auto', 'color', 'auto-monochrome', 'monochrome'),
    allowNull: false,
    defaultValue: 'monochrome'
  },
  quality: {
    type: DataTypes.ENUM('draft', 'normal', 'high'),
    allowNull: false,
    defaultValue: 'normal'
  },
  format: {
    type: DataTypes.ENUM('image/urf', 'image/pwg-raster', 'application/octet-stream', 'application/pdf'),
    allowNull: false,
    defaultValue: 'application/octet-stream'
  },
  duplex: {
    type: DataTypes.BOOLEAN,
    allowNull: false,
    defaultValue: false
  },
  errorMessage: {
    type: DataTypes.TEXT,
    allowNull: true
  },
  createdAt: {
    type: DataTypes.DATE,
    allowNull: false,
    defaultValue: DataTypes.NOW
  },
  updatedAt: {
    type: DataTypes.DATE,
    allowNull: false,
    defaultValue: DataTypes.NOW
  }
});

module.exports = { Task }; 